package com.itec.learn.java.design.observer.jive;

import java.util.ArrayList;
import java.util.List;

/**
 * 论坛帖子
 * @author chenyiqun
 */
public class ForumThread {

    private int id;

    private String title;

    private List<String> messageList = new ArrayList<String>();

    private ForumFactory factory;

    public ForumThread(String title,String message,ForumFactory factory){
        this.title = title;
        messageList.add(message);
        this.factory = factory;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<String> getMessageList() {
        return messageList;
    }

    public void setMessageList(List<String> messageList) {
        this.messageList = messageList;
    }

    public void addMessage(String msg){
        messageList.add(msg);
        factory.watchManager.notifyWatches(this);
    }
}
